<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtiframe.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class manage_tires extends Page
{
       public $lblmodel = null;
       public $lblmake = null;
       public $Label43 = null;
       public $Label31 = null;
       public $lblyear = null;
       public $lblplate = null;
       public $lblEmpName = null;
       public $lblEmpId = null;
       public $Label33 = null;
       public $Image9 = null;
       public $Image8 = null;
       public $JTDivInfo = null;
       public $imgInfo = null;
       public $Label26 = null;
       public $hfStartOdometer = null;
       public $hfTrackBy = null;
       public $editMountKm = null;
       public $lblKm = null;
       public $lblOdometer2 = null;
       public $lblOdometer = null;
       public $lblkm2 = null;
       public $editDismountKm = null;
       public $hfSpare = null;
       public $hfSpareTire = null;
       public $img_spare = null;
       public $Label48 = null;
       public $lblVeh = null;
       public $editMountCost = null;
       public $editMountCostUnit = null;
       public $editDismountPressure = null;
       public $editDismountTread = null;
       public $editDismountWheel = null;
       public $editDismountAxle = null;
       public $JTGroupBox2 = null;
       public $Label44 = null;
       public $Label42 = null;
       public $Label25 = null;
       public $Label24 = null;
       public $Label23 = null;
       public $Label22 = null;
       public $Label21 = null;
       public $editMountPressure = null;
       public $Label9 = null;
       public $Label20 = null;
       public $editMountTread = null;
       public $Label8 = null;
       public $editMountWheel = null;
       public $Label7 = null;
       public $editMountAxle = null;
       public $Label6 = null;
       public $JTGroupBox1 = null;
       public $Label19 = null;
       public $Label18 = null;
       public $Label17 = null;
       public $Image7 = null;
       public $Image6 = null;
       public $Image5 = null;
       public $Label16 = null;
       public $JTTireHistory = null;
       public $JTFrameTireList = null;
       public $lbl6 = null;
       public $lbl5 = null;
       public $lbl4 = null;
       public $lbl3 = null;
       public $lbl2 = null;
       public $lbl1 = null;
       public $lblRO = null;
       public $lblRI = null;
       public $lblLI = null;
       public $lblLO = null;
       public $Image4 = null;
       public $Image3 = null;
       public $Image2 = null;
       public $img_right_out_1 = null;
       public $img_right_in_1 = null;
       public $img_left_out_1 = null;
       public $img_left_in_1 = null;
       public $img_bar_1 = null;
       public $img_right_out_6 = null;
       public $img_right_in_6 = null;
       public $img_left_out_6 = null;
       public $img_left_in_6 = null;
       public $img_bar_6 = null;
       public $img_right_out_5 = null;
       public $img_right_in_5 = null;
       public $img_left_out_5 = null;
       public $img_left_in_5 = null;
       public $img_bar_5 = null;
       public $img_right_out_4 = null;
       public $img_right_in_4 = null;
       public $img_left_out_4 = null;
       public $img_left_in_4 = null;
       public $img_bar_4 = null;
       public $img_right_out_3 = null;
       public $img_right_in_3 = null;
       public $img_left_out_3 = null;
       public $img_left_in_3 = null;
       public $img_bar_3 = null;
       public $img_right_out_2 = null;
       public $img_right_in_2 = null;
       public $img_left_out_2 = null;
       public $img_left_in_2 = null;
       public $img_bar_2 = null;
       public $imgBack = null;
       public $Image1 = null;
       public $hfAjaxType = null;
       public $hfTireIdEdit = null;
       public $memoDismountComments = null;
       public $cmbDismountAccount = null;
       public $cmbDismountWorkby = null;
       public $editDismountCostUnit = null;
       public $editDismountLaborUnit = null;
       public $radioDismountWorkBy = null;
       public $editDismountOrderNo = null;
       public $chkDismountRecord = null;
       public $editDismountDescription = null;
       public $editDismountVIN = null;
       public $editDismountCost = null;
       public $editDismountType = null;
       public $editDismountOdometer = null;
       public $dpDismountDate = null;
       public $Label40 = null;
       public $Label39 = null;
       public $Label38 = null;
       public $Label37 = null;
       public $Label36 = null;
       public $Label35 = null;
       public $Label30 = null;
       public $Label29 = null;
       public $Label28 = null;
       public $Label27 = null;
       public $Label2 = null;
       public $btnDismountCancel = null;
       public $btnMountCancel = null;
       public $radioMountWorkBy = null;
       public $hfDescTireSn = null;
       public $Description = null;
       public $editMountDescription = null;
       public $JTJSMountTire = null;
       public $Label15 = null;
       public $memoMountComments = null;
       public $cmbMountAccount = null;
       public $Label14 = null;
       public $Label13 = null;
       public $cmbMountWorkType = null;
       public $editMountLaborUnit = null;
       public $editMountOrderNo = null;
       public $Label12 = null;
       public $Label11 = null;
       public $Label10 = null;
       public $chkMountRecord = null;
       public $editMountVIN = null;
       public $Label4 = null;
       public $editMountType = null;
       public $editMountOdometer = null;
       public $Label5 = null;
       public $Label3 = null;
       public $dpMountDate = null;
       public $btnDismount = null;
       public $JTDivDismount = null;
       public $Label1 = null;
       public $hfTirePosIdSave = null;
       public $hfTirePosMountSave = null;
       public $hiddenTireIdSave = null;
       public $btnAdd = null;
       public $JTDivAdd = null;
       public $JTSiteTheme1 = null;
       public $hfRO6 = null;
       public $hfRO5 = null;
       public $hfRO4 = null;
       public $hfRO3 = null;
       public $hfRO2 = null;
       public $hfRO1 = null;
       public $hfRI6 = null;
       public $hfRI5 = null;
       public $hfRI4 = null;
       public $hfRI3 = null;
       public $hfRI2 = null;
       public $hfRI1 = null;
       public $hfLI6 = null;
       public $hfLI5 = null;
       public $hfLI4 = null;
       public $hfLI3 = null;
       public $hfLI2 = null;
       public $hfLO6 = null;
       public $hfLO5 = null;
       public $hfLO4 = null;
       public $hfLO3 = null;
       public $hfLO2 = null;
       public $hfLI1 = null;
       public $hfLO1 = null;
       public $hfRightOut6 = null;
       public $hfRightOut5 = null;
       public $hfRightOut4 = null;
       public $hfRightOut3 = null;
       public $hfRightOut2 = null;
       public $hfRightOut1 = null;
       public $hfRightIn6 = null;
       public $hfRightIn5 = null;
       public $hfRightIn4 = null;
       public $hfRightIn3 = null;
       public $hfRightIn2 = null;
       public $hfRightIn1 = null;
       public $hfLeftIn6 = null;
       public $hfLeftIn5 = null;
       public $hfLeftIn4 = null;
       public $hfLeftIn3 = null;
       public $hfLeftIn2 = null;
       public $hfLeftOut6 = null;
       public $hfLeftOut5 = null;
       public $hfLeftOut4 = null;
       public $hfLeftOut3 = null;
       public $hfLeftOut2 = null;
       public $hfLeftIn1 = null;
       public $hfLeftOut1 = null;
       public $hiddenVin = null;
       function editMountCostJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       //accept only numbers
       var numero = document.getElementById("editMountCost").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("editMountCost").value = numero;
       <?php

       }

       function editDismountCostUnitJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       //accept only numbers
       var numero = document.getElementById("editDismountCostUnit").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("editDismountCostUnit").value = numero;
       <?php

       }

       function imgInfoJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivInfo').Show();
       <?php

       }

       function editDismountKmJSKeyUp($sender, $params)
       {

       ?>
       var start_odometer = document.getElementById('hfStartOdometer');
       var edit_odometer = document.getElementById('editDismountOdometer');
       var km_run = document.getElementById('editDismountKm');

       edit_odometer.value = Number(km_run.value) + Number(start_odometer.value);
       <?php

       }

       function editMountKmJSKeyUp($sender, $params)
       {

       ?>
       var start_odometer = document.getElementById('hfStartOdometer');
       var edit_odometer = document.getElementById('editMountOdometer');
       var km_run = document.getElementById('editMountKm');

       edit_odometer.value = Number(km_run.value) + Number(start_odometer.value);
       <?php

       }

       function editDismountOdometerJSKeyUp($sender, $params)
       {

       ?>
       var track_by = document.getElementById('hfTrackBy').value;
       if(track_by=='distance')
       {
       var start_odometer = document.getElementById('hfStartOdometer');
       var edit_odometer = document.getElementById('editDismountOdometer');
       var km_run = document.getElementById('editDismountKm');

       km_run.value = Number(edit_odometer.value) - Number(start_odometer.value);
       }
       <?php

       }

       function editMountOdometerJSKeyUp($sender, $params)
       {

       ?>
       var track_by = document.getElementById('hfTrackBy').value;
       if(track_by=='distance')
       {
       var start_odometer = document.getElementById('hfStartOdometer');
       var edit_odometer = document.getElementById('editMountOdometer');
       var km_run = document.getElementById('editMountKm');

       km_run.value = Number(edit_odometer.value) - Number(start_odometer.value);
       }
       <?php

       }

       function img_spareJSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfSpare').value;
       document.getElementById('hfTirePosMountSave').value='spare_mount';
       document.getElementById('hfTirePosIdSave').value='spare_tire_id';

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '';
       document.getElementById("editDismountWheel").value = 'Spare';

       var tire_id = document.getElementById('hfSpare').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '';
       document.getElementById("editMountWheel").value = 'Spare';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Add Spare Tire ID/SN:'+' '+hfDescTireSn;
       }
       <?php

       }

       function manage_tiresJSLoad($sender, $params)
       {

       ?>
       document.getElementById('editDismountType').style.visibility = 'hidden';
       document.getElementById('editMountCostUnit').style.visibility = 'hidden';
       document.getElementById('Label27').style.visibility = 'hidden';
       document.getElementById('Label1').style.visibility = 'hidden';
       document.getElementById('editDismountCost').style.visibility = 'hidden';
       document.getElementById('editMountType').style.visibility = 'hidden';
       document.getElementById('Label28').style.visibility = 'hidden';
       document.getElementById('Label5').style.visibility = 'hidden';
       <?php

       }


       function Button2JSClick($sender, $params)
       {

       ?>
       var echo = document.getElementById('hiddenTireIdSave').value;
       alert('insert'+echo);
       <?php

       }

       function Button1JSClick($sender, $params)
       {

       ?>
       var echo = document.getElementById('hfTireIdEdit').value;
       alert('edit'+echo);
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }
       function btnDismountClick($sender, $params)
       {
       $track_by = $this->hfTrackBy->getValue();
       if($track_by=="distance");
       {
        $save_track = "odometer";
       }
       if($track_by=="hours");
       {
        $save_track = "hours";
       }

       $vin = $this->hiddenVin->getValue();
       $company_id = $_SESSION['company_id'];

       $query_up_chassis_tire = "UPDATE veh_chassis_tire_tbl SET
        ".$this->hfTirePosMountSave->getValue()."='0',
        ".$this->hfTirePosIdSave->getValue()."='0'
        WHERE vehicle_id='".$vin."'";
        mysql_query($query_up_chassis_tire) or die("UPDATE VEH_CHASSIS_TIRE ".mysql_error());

        $query_up_tire_inv = "UPDATE tire_inventory_tbl SET status='0',mounted_on='0',mounted_post='-' WHERE tire_id='".$this->hfTireIdEdit->getValue()."'";
        mysql_query($query_up_tire_inv) or die("UPDATE TIRE INVENTORY ".mysql_error());


        $radio_workby = $this->radioDismountWorkBy->getItemIndex();
        if($radio_workby==0)
        $work_by = 'employee';
        if($radio_workby==1)
        $work_by = 'vendor';

        $labor = intval($this->editDismountLaborUnit->Text) * intval($this->editDismountCostUnit->Text);

        $check_record = $this->chkDismountRecord->Checked;

        $query_account = "SELECT value FROM lookup_expense_tbl WHERE id='".$this->cmbDismountAccount->getItemIndex()."'";
        $result_account = mysql_query($query_account) or die("ACCOUNT ".mysql_error());
        $row_account = mysql_fetch_array($result_account);
        $account_name = $row_account['value'];

        if($check_record==1)
        {
        $new_wo = $this->generate_workorder();
        $query_insert_workorder = "INSERT INTO veh_workorder_tbl (
        company_id,
        vehicle_id,
        work_by_id,
        work_by,
        creation_date,
        order_num,
        ".$save_track.",
        account,
        description,
        full_desc,
        status,
        labor,
        total,
        complete
        )
        VALUES
        (
        '".$company_id."',
        '".$vin."',
        '".$this->cmbDismountWorkby->getItemIndex()."',
        '".$work_by."',
        '".$this->dpDismountDate->getDate()."',
        '".$new_wo."',
        '".$this->editDismountOdometer->Text."',
        '".$account_name."',
        'Tire Service',
        '".$this->editDismountDescription->Text."',
        'complete',
        '".$labor."',
        '".$labor."',
        '1'
        )
        ";
        mysql_query($query_insert_workorder) or die("INSERT WORKORDER ".mysql_error());

        $result_last_wo_id = mysql_query("SELECT last_insert_id(workorder_id) as last_id FROM veh_workorder_tbl ORDER BY workorder_id DESC LIMIT 0,1") or die("LAST INSERT ID WORKORDER ".mysql_error());
        $row_last_id = mysql_fetch_array($result_last_wo_id);
        $last_wo_id = $row_last_id['last_id'];

        if($work_by=='employee')
        {
         $query_emp = "SELECT lname, fname FROM employee_tbl WHERE autoid='".$this->cmbDismountWorkby->getItemIndex()."'";
         $result_emp = mysql_query($query_emp) or die("COMBO EMPLOYEE ".mysql_error());
         $row_emp = mysql_fetch_array($result_emp);
         $employee_name = $row_emp['lname'].', '.$row_emp['fname'];
        }
        if($work_by=='vendor')
        {
         $query_vend = "SELECT vendor_name FROM vendor_tbl WHERE vendor_id='".$this->cmbDismountWorkby->getItemIndex()."'";
         $result_vend = mysql_query($query_vend) or die("COMBO VENDOR ".mysql_error());
         $row_vend = mysql_fetch_array($result_vend);
         $employee_name = $row_vend['vendor_name'];
        }

        $query_insert_laborline = "INSERT INTO veh_laborline_tbl (
        company_id,
        vehicle_id,
        workorder,
        performed_by,
        employee,
        labor_date,
        labor_unit,
        cost,
        total,
        description
        )
        VALUES (
        '".$company_id."',
        '".$vin."',
        '".$last_wo_id."',
        '".$work_by."',
        '".$employee_name."',
        '".$this->dpDismountDate->getDate()."',
        '".$this->editDismountLaborUnit->Text."',
        '".$this->editDismountCostUnit->Text."',
        '".$labor."',
        '".$this->editDismountDescription->Text."'
        )";
        //die($query_insert_laborline);
        mysql_query($query_insert_laborline) or die("INSERT LABORLINE ".mysql_error());

        $query_sel_last_wo = "SELECT order_num FROM veh_workorder_tbl WHERE workorder_id='".$last_wo_id."'";
        $result_sel_last_wo = mysql_query($query_sel_last_wo) or die("SELECT LAST WO ".mysql_error());
        $row_sel_last_wo = mysql_fetch_array($result_sel_last_wo);
        $wo_num = $row_sel_last_wo['order_num'];

       //UPDATE WORKORDER COUNTER - COMPANY WORKORDERS TBL
       $result_last_order_num = mysql_query("SELECT last_order_no as last from company_workorders_tbl WHERE
       company_id='".$company_id."'") or die("get last order ".mysql_error());
       $row_lon = mysql_fetch_array($result_last_order_num);
       //var_dump($row_lon);
       $lon = $row_lon['last'];
       $lon++;
       mysql_query("UPDATE company_workorders_tbl SET last_order_no='".$lon."' WHERE
       company_id='".$company_id."'") or die("update last company rec ".mysql_error());
       }

       if($check_record==0)
       {
        $wo_num = 'n/a';
       }

       $location = $this->editDismountAxle->Text.'-'.$this->editDismountWheel->Text;

       $query_insert_journal = "INSERT INTO tire_srvcejournal_tbl (
       company_id,
       vehicle_id,
       tire_id,
       date,
       ".$save_track.",
       type,
       tire_cost,
       location,
       description,
       axle,
       wheel,
       tread,
       pressure,
       record_wo,
       emp_vendor,
       wo_num,
       labor_unit,
       cost_unit,
       worked_by,
       acct_num,
       comments
       ) VALUES
       (
       '".$company_id."',
       '".$this->hiddenVin->getValue()."',
       '".$this->hfTireIdEdit->getValue()."',
       '".$this->dpDismountDate->getDate()."',
       '".$this->editDismountOdometer->Text."',
       '".$this->editDismountType->Text."',
       '".$this->editDismountCost->Text."',
       '".$location."',
       '".$this->editDismountDescription->Text."',
       '".$this->editDismountAxle->Text."',
       '".$this->editDismountWheel->Text."',
       '".$this->editDismountTread->Text."',
       '".$this->editDismountPressure->Text."',
       '".$check_record."',
       '".$this->cmbDismountWorkby->getItemIndex()."',
       '".$wo_num."',
       '".$this->editDismountLaborUnit->Text."',
       '".$this->editDismountCostUnit->Text."',
       '".$work_by."',
       '".$account_name."',
       '".$this->memoDismountComments->Text."'
       )";
       mysql_query($query_insert_journal) or die("INSERT JOURNAL ".mysql_error());

       $date = date('m-d-Y');
       $query_ins_tread_wear = "INSERT INTO tire_tread_wear_tbl
       (tire_id,tread,pressure,".$save_track.",mounted_on,insert_date)
       VALUE
       ('".$this->hfTireIdEdit->getValue()."',
       '".$this->editDismountTread->Text."',
       '".$this->editDismountPressure->Text."',
       '".$this->editDismountOdometer->Text."',
       '".$this->hiddenVin->getValue()."',
       '".$date."')";
       mysql_query($query_ins_tread_wear) or die("INSERT TREAD WEAR ".mysql_error());

       redirect('manage_tires.php?vin='.$vin);
       }


       function btnDismountCancelJSClick($sender, $params)
       {

       ?>
       document.getElementById("JTDivDismount").Hide();

       <?php

       }

       function btnMountCancelJSClick($sender, $params)
       {

       ?>
       document.getElementById("JTDivAdd").Hide();
       <?php

       }

       function chkMountRecordJSChange($sender, $params)
       {
       ?>
       var flag_check = document.getElementById('chkMountRecord').checked;
       var editBox = document.getElementById('editMountOrderNo');
       if(flag_check==0)
       {
        editBox.readOnly = true;
       }
       if(flag_check==1)
       {
        editBox.readOnly = false;
       }
       return false;

       <?php

       }

       function processWorkByCombo2()
       {
       $company_id = $_SESSION['company_id'];
       //type  0 = employee  1 = vendor
       $this->cmbDismountWorkby->Clear();
       $this->cmbDismountWorkby->AddItem('', null,'');

       $type = $this->radioDismountWorkBy->getItemIndex();
       if($type==0)
       {
        $query_combo_work_by = "SELECT autoid, fname, lname FROM employee_tbl WHERE company_id='".$company_id."' AND
        (job_title='Driver' OR job_title='Fleet Technician')";
        $result_combo_work_by = mysql_query($query_combo_work_by) or die('COMBO WORK BY '.mysql_error());
        while($row_combo_work_by = mysql_fetch_array($result_combo_work_by))
        {
         $id = $row_combo_work_by['autoid'];
         $name = $row_combo_work_by['fname'].'&nbsp;'.$row_combo_work_by['lname'];
         $this->cmbDismountWorkby->AddItem($name,null,$id);
        }
       }
       if($type==1)
       {
        $query_combo_work_by = "SELECT vendor_id, vendor_name FROM vendor_tbl WHERE company_id='".$company_id."'";
        $result_combo_work_by = mysql_query($query_combo_work_by) or die('COMBO WORK BY '.mysql_error());
        while($row_combo_work_by = mysql_fetch_array($result_combo_work_by))
        {
         $id = $row_combo_work_by['vendor_id'];
         $name = $row_combo_work_by['vendor_name'];
         $this->cmbDismountWorkby->AddItem($name,null,$id);
        }
       }
       }

       function processWorkByCombo()
       {
       //die($this->radioMountWorkBy->getItemIndex());
       $company_id = $_SESSION['company_id'];
       //type  0 = employee  1 = vendor
       $this->cmbMountWorkType->Clear();
       $this->cmbMountWorkType->AddItem('', null,'');
       $type = $this->radioMountWorkBy->getItemIndex();

       /*echo"<script language=javascript>
        alert('".$type."');
        </script>";*/

       if($type==0)
       {
        $query_combo_work_by = "SELECT autoid, fname, lname FROM employee_tbl WHERE company_id='".$company_id."' AND
        (job_title='Driver' OR job_title='Fleet Technician')";
        $result_combo_work_by = mysql_query($query_combo_work_by) or die('COMBO WORK BY '.mysql_error());
        while($row_combo_work_by = mysql_fetch_array($result_combo_work_by))
        {
         $id = $row_combo_work_by['autoid'];
         $name = $row_combo_work_by['fname'].'&nbsp;'.$row_combo_work_by['lname'];
         $this->cmbMountWorkType->AddItem($name,null,$id);
        }
       }
       if($type==1)
       {

        $query_combo_work_by = "SELECT vendor_id, vendor_name FROM vendor_tbl WHERE company_id='".$company_id."'";
        $result_combo_work_by = mysql_query($query_combo_work_by) or die('COMBO WORK BY '.mysql_error());
        while($row_combo_work_by = mysql_fetch_array($result_combo_work_by))
        {
         $id = $row_combo_work_by['vendor_id'];
         $name = $row_combo_work_by['vendor_name'];
         $this->cmbMountWorkType->AddItem($name,null,$id);
        }
       }
       }

       function radioMountWorkByJSChange($sender, $params)
       {
       echo $this->radioMountWorkBy->ajaxCall("processWorkByCombo");
       ?>
       return false;
       <?php

       }
       function radioDismountWorkByJSChange($sender, $params)
       {
       echo $this->radioMountWorkBy->ajaxCall("processWorkByCombo2");
       ?>
       //Add your javascript code here

       <?php

       }

       function btnAddClick($sender, $params)
       {
       $track_by = $this->hfTrackBy->getValue();
       if($track_by=="distance");
       {
        $save_track = "odometer";
       }
       if($track_by=="hours");
       {
        $save_track = "hours";
       }

       $vin = $this->hiddenVin->getValue();
       $company_id = $_SESSION['company_id'];

        $query_up_chassis_tire = "UPDATE veh_chassis_tire_tbl SET
        ".$this->hfTirePosMountSave->getValue()."='1',
        ".$this->hfTirePosIdSave->getValue()."='".$this->hiddenTireIdSave->getValue()."'
        WHERE vehicle_id='".$vin."'";
        mysql_query($query_up_chassis_tire) or die("UPDATE VEH_CHASSIS_TIRE ".mysql_error());

        $query_up_tire_inv = "UPDATE tire_inventory_tbl SET status='1',mounted_on='".$vin."',mounted_post='".$this->editMountAxle->Text."-".$this->editMountWheel->Text."' WHERE tire_id='".$this->hiddenTireIdSave->getValue()."'";
        mysql_query($query_up_tire_inv) or die("UPDATE TIRE INVENTORY ".mysql_error());

        $radio_workby = $this->radioMountWorkBy->getItemIndex();
        if($radio_workby==0)
        $work_by = 'employee';
        if($radio_workby==1)
        $work_by = 'vendor';

        $labor = intval($this->editMountLaborUnit->Text) * intval($this->editMountCost->Text);

        $check_record = $this->chkMountRecord->Checked;

        $query_account = "SELECT value FROM lookup_expense_tbl WHERE id='".$this->cmbMountAccount->getItemIndex()."'";
        $result_account = mysql_query($query_account) or die("ACCOUNT ".mysql_error());
        $row_account = mysql_fetch_array($result_account);
        $account_name = $row_account['value'];

        if($check_record==1)
        {
        $new_wo = $this->generate_workorder();
        $query_insert_workorder = "INSERT INTO veh_workorder_tbl (
        company_id,
        vehicle_id,
        work_by_id,
        work_by,
        creation_date,
        order_num,
        ".$save_track.",
        account,
        description,
        full_desc,
        status,
        labor,
        total,
        complete
        )
        VALUES
        (
        '".$company_id."',
        '".$vin."',
        '".$this->cmbMountWorkType->getItemIndex()."',
        '".$work_by."',
        '".$this->dpMountDate->getDate()."',
        '".$new_wo."',
        '".$this->editMountOdometer->Text."',
        '".$account_name."',
        'Tire Service',
        '".$this->editMountDescription->Text."',
        'complete',
        '".$labor."',
        '".$labor."',
        '1'
        )
        ";
        mysql_query($query_insert_workorder) or die("INSERT WORKORDER ".mysql_error());

        $result_last_wo_id = mysql_query("SELECT last_insert_id(workorder_id) as last_id FROM veh_workorder_tbl ORDER BY workorder_id DESC LIMIT 0,1") or die("LAST INSERT ID WORKORDER ".mysql_error());
        $row_last_id = mysql_fetch_array($result_last_wo_id);
        $last_wo_id = $row_last_id['last_id'];

        if($work_by=='employee')
        {
         $query_emp = "SELECT lname, fname FROM employee_tbl WHERE autoid='".$this->cmbMountWorkType->getItemIndex()."'";
         $result_emp = mysql_query($query_emp) or die("COMBO EMPLOYEE ".mysql_error());
         $row_emp = mysql_fetch_array($result_emp);
         $employee_name = $row_emp['lname'].', '.$row_emp['fname'];
        }
        if($work_by=='vendor')
        {
         $query_vend = "SELECT vendor_name FROM vendor_tbl WHERE vendor_id='".$this->cmbMountWorkType->getItemIndex()."'";
         $result_vend = mysql_query($query_vend) or die("COMBO VENDOR ".mysql_error());
         $row_vend = mysql_fetch_array($result_vend);
         $employee_name = $row_vend['vendor_name'];
        }

        $query_insert_laborline = "INSERT INTO veh_laborline_tbl (
        company_id,
        vehicle_id,
        workorder,
        performed_by,
        employee,
        labor_date,
        labor_unit,
        cost,
        total,
        description
        )
        VALUES (
        '".$company_id."',
        '".$vin."',
        '".$last_wo_id."',
        '".$work_by."',
        '".$employee_name."',
        '".$this->dpMountDate->getDate()."',
        '".$this->editMountLaborUnit->Text."',
        '".$this->editMountCost->Text."',
        '".$labor."',
        '".$this->editMountDescription->Text."'
        )";
        //die($query_insert_laborline);
        mysql_query($query_insert_laborline) or die("INSERT LABORLINE ".mysql_error());

        $query_sel_last_wo = "SELECT order_num FROM veh_workorder_tbl WHERE workorder_id='".$last_wo_id."'";
        $result_sel_last_wo = mysql_query($query_sel_last_wo) or die("SELECT LAST WO ".mysql_error());
        $row_sel_last_wo = mysql_fetch_array($result_sel_last_wo);
        $wo_num = $row_sel_last_wo['order_num'];

        //UPDATE WORKORDER COUNTER - COMPANY WORKORDERS TBL
       $result_last_order_num = mysql_query("SELECT last_order_no as last from company_workorders_tbl WHERE
       company_id='".$company_id."'") or die("get last order ".mysql_error());
       $row_lon = mysql_fetch_array($result_last_order_num);
       //var_dump($row_lon);
       $lon = $row_lon['last'];
       $lon++;
       mysql_query("UPDATE company_workorders_tbl SET last_order_no='".$lon."' WHERE
       company_id='".$company_id."'") or die("update last company rec ".mysql_error());
       }

       if($check_record==0)
       {
        $wo_num = 'n/a';
       }

       $location = $this->editMountAxle->Text.'-'.$this->editMountWheel->Text;

       $query_insert_journal = "INSERT INTO tire_srvcejournal_tbl (
       company_id,
       vehicle_id,
       tire_id,
       date,
       ".$save_track.",
       type,
       tire_cost,
       location,
       description,
       axle,
       wheel,
       tread,
       pressure,
       record_wo,
       emp_vendor,
       wo_num,
       labor_unit,
       cost_unit,
       worked_by,
       acct_num,
       comments
       ) VALUES
       (
       '".$company_id."',
       '".$this->hiddenVin->getValue()."',
       '".$this->hiddenTireIdSave->getValue()."',
       '".$this->dpMountDate->getDate()."',
       '".$this->editMountOdometer->Text."',
       '".$this->editMountType->Text."',
       '".$this->editMountCost->Text."',
       '".$location."',
       '".$this->editMountDescription->Text."',
       '".$this->editMountAxle->Text."',
       '".$this->editMountWheel->Text."',
       '".$this->editMountTread->Text."',
       '".$this->editMountPressure->Text."',
       '".$check_record."',
       '".$this->cmbMountWorkType->getItemIndex()."',
       '".$wo_num."',
       '".$this->editMountLaborUnit->Text."',
       '".$this->editMountCost->Text."',
       '".$work_by."',
       '".$account_name."',
       '".$this->memoMountComments->Text."'
       )";
       mysql_query($query_insert_journal) or die("INSERT JOURNAL ".mysql_error());

       $date = date('m-d-Y');
       $query_ins_tread_wear = "INSERT INTO tire_tread_wear_tbl
       (tire_id,tread,pressure,".$save_track.",mounted_on,insert_date)
       VALUE
       ('".$this->hiddenTireIdSave->getValue()."',
       '".$this->editMountTread->Text."',
       '".$this->editMountPressure->Text."',
       '".$this->editMountOdometer->Text."',
       '".$this->hiddenVin->getValue()."',
       '".$date."')";
       mysql_query($query_ins_tread_wear) or die("INSERT TREAD WEAR ".mysql_error());

       redirect('manage_tires.php?vin='.$vin);
       }


       function img_right_out_6JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRO6').value;
       document.getElementById('hfTirePosMountSave').value='ro6_mount';
       document.getElementById('hfTirePosIdSave').value='ro6_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '6';
       document.getElementById("editDismountWheel").value = 'RO';

       var tire_id = document.getElementById('hfRO6').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '6';
       document.getElementById("editMountWheel").value = 'RO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_in_6JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRI6').value;
       document.getElementById('hfTirePosMountSave').value='ri6_mount';
       document.getElementById('hfTirePosIdSave').value='ri6_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '6';
       document.getElementById("editDismountWheel").value = 'RI';

       var tire_id = document.getElementById('hfRI6').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '6';
       document.getElementById("editMountWheel").value = 'RI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_in_6JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLI6').value;
       document.getElementById('hfTirePosMountSave').value='li6_mount';
       document.getElementById('hfTirePosIdSave').value='li6_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '6';
       document.getElementById("editDismountWheel").value = 'LI';

       var tire_id = document.getElementById('hfLI6').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '6';
       document.getElementById("editMountWheel").value = 'LI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_out_6JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLO6').value;
       document.getElementById('hfTirePosMountSave').value='lo6_mount';
       document.getElementById('hfTirePosIdSave').value='lo6_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '6';
       document.getElementById("editDismountWheel").value = 'LO';

       var tire_id = document.getElementById('hfLO6').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '6';
       document.getElementById("editMountWheel").value = 'LO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_out_5JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRO5').value;
       document.getElementById('hfTirePosMountSave').value='ro5_mount';
       document.getElementById('hfTirePosIdSave').value='ro5_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '5';
       document.getElementById("editDismountWheel").value = 'RO';

       var tire_id = document.getElementById('hfRO5').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '5';
       document.getElementById("editMountWheel").value = 'RO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_in_5JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRI5').value;
       document.getElementById('hfTirePosMountSave').value='ri5_mount';
       document.getElementById('hfTirePosIdSave').value='ri5_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '5';
       document.getElementById("editDismountWheel").value = 'RI';

       var tire_id = document.getElementById('hfRI5').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '5';
       document.getElementById("editMountWheel").value = 'RI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_in_5JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLI5').value;
       document.getElementById('hfTirePosMountSave').value='li5_mount';
       document.getElementById('hfTirePosIdSave').value='li5_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '5';
       document.getElementById("editDismountWheel").value = 'LI';

       var tire_id = document.getElementById('hfLI5').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '5';
       document.getElementById("editMountWheel").value = 'LI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_out_5JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLO5').value;
       document.getElementById('hfTirePosMountSave').value='lo5_mount';
       document.getElementById('hfTirePosIdSave').value='lo5_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '5';
       document.getElementById("editDismountWheel").value = 'LO';

       var tire_id = document.getElementById('hfLO5').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '5';
       document.getElementById("editMountWheel").value = 'LO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_out_4JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRO4').value;
       document.getElementById('hfTirePosMountSave').value='ro4_mount';
       document.getElementById('hfTirePosIdSave').value='ro4_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '4';
       document.getElementById("editDismountWheel").value = 'RO';

       var tire_id = document.getElementById('hfRO4').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '4';
       document.getElementById("editMountWheel").value = 'RO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_in_4JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRI4').value;
       document.getElementById('hfTirePosMountSave').value='ri4_mount';
       document.getElementById('hfTirePosIdSave').value='ri4_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '4';
       document.getElementById("editDismountWheel").value = 'RI';

       var tire_id = document.getElementById('hfRI4').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '4';
       document.getElementById("editMountWheel").value = 'RI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_in_4JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLI4').value;
       document.getElementById('hfTirePosMountSave').value='li4_mount';
       document.getElementById('hfTirePosIdSave').value='li4_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '4';
       document.getElementById("editDismountWheel").value = 'LI';

       var tire_id = document.getElementById('hfLI4').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '4';
       document.getElementById("editMountWheel").value = 'LI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_out_4JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLO4').value;
       document.getElementById('hfTirePosMountSave').value='lo4_mount';
       document.getElementById('hfTirePosIdSave').value='lo4_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '4';
       document.getElementById("editDismountWheel").value = 'LO';

       var tire_id = document.getElementById('hfLO4').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '4';
       document.getElementById("editMountWheel").value = 'LO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_out_3JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRO3').value;
       document.getElementById('hfTirePosMountSave').value='ro3_mount';
       document.getElementById('hfTirePosIdSave').value='ro3_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '3';
       document.getElementById("editDismountWheel").value = 'RO';

       var tire_id = document.getElementById('hfRO3').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '3';
       document.getElementById("editMountWheel").value = 'RO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_in_3JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRI3').value;
       document.getElementById('hfTirePosMountSave').value='ri3_mount';
       document.getElementById('hfTirePosIdSave').value='ri3_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '3';
       document.getElementById("editDismountWheel").value = 'RI';

       var tire_id = document.getElementById('hfRI3').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '3';
       document.getElementById("editMountWheel").value = 'RI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_in_3JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLI3').value;
       document.getElementById('hfTirePosMountSave').value='li3_mount';
       document.getElementById('hfTirePosIdSave').value='li3_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '3';
       document.getElementById("editDismountWheel").value = 'LI';

       var tire_id = document.getElementById('hfLI3').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '3';
       document.getElementById("editMountWheel").value = 'LI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_out_3JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLO3').value;
       document.getElementById('hfTirePosMountSave').value='lo3_mount';
       document.getElementById('hfTirePosIdSave').value='lo3_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '3';
       document.getElementById("editDismountWheel").value = 'LO';

       var tire_id = document.getElementById('hfLO3').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '3';
       document.getElementById("editMountWheel").value = 'LO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_out_2JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRO2').value;
       document.getElementById('hfTirePosMountSave').value='ro2_mount';
       document.getElementById('hfTirePosIdSave').value='ro2_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '2';
       document.getElementById("editDismountWheel").value = 'RO';

       var tire_id = document.getElementById('hfRO2').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '2';
       document.getElementById("editMountWheel").value = 'RO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_in_2JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRI2').value;
       document.getElementById('hfTirePosMountSave').value='ri2_mount';
       document.getElementById('hfTirePosIdSave').value='ri2_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '2';
       document.getElementById("editDismountWheel").value = 'RI';

       var tire_id = document.getElementById('hfRI2').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '2';
       document.getElementById("editMountWheel").value = 'RI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn+' '+'on VIN:'+hiddenVin+' Axle:'+axle+' Pos:'+wheel;
       //alert('mount');
       }
       <?php

       }

       function img_left_in_2JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLI2').value;
       document.getElementById('hfTirePosMountSave').value='li2_mount';
       document.getElementById('hfTirePosIdSave').value='li2_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '2';
       document.getElementById("editDismountWheel").value = 'LI';

       var tire_id = document.getElementById('hfLI2').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '2';
       document.getElementById("editMountWheel").value = 'LI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_out_2JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLO2').value;
       document.getElementById('hfTirePosMountSave').value='lo2_mount';
       document.getElementById('hfTirePosIdSave').value='lo2_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '2';
       document.getElementById("editDismountWheel").value = 'LO';

       var tire_id = document.getElementById('hfLO2').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '2';
       document.getElementById("editMountWheel").value = 'LO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_right_in_1JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRI1').value;
       document.getElementById('hfTirePosMountSave').value='ri1_mount';
       document.getElementById('hfTirePosIdSave').value='ri1_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '1';
       document.getElementById("editDismountWheel").value = 'RI';

       var tire_id = document.getElementById('hfRI1').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '1';
       document.getElementById("editMountWheel").value = 'RI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php

       }

       function img_left_in_1JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfLI1').value;
       document.getElementById('hfTirePosMountSave').value='li1_mount';
       document.getElementById('hfTirePosIdSave').value='li1_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '1';
       document.getElementById("editDismountWheel").value = 'LI';

       var tire_id = document.getElementById('hfLI1').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '1';
       document.getElementById("editMountWheel").value = 'LI';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }

       <?php

       }

       function img_right_out_1JSClick($sender, $params)
       {

       ?>
       var type = document.getElementById('hfRO1').value;
       document.getElementById('hfTirePosMountSave').value='ro1_mount';
       document.getElementById('hfTirePosIdSave').value='ro1_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '1';
       document.getElementById("editDismountWheel").value = 'RO';

       var tire_id = document.getElementById('hfRO1').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '1';
       document.getElementById("editMountWheel").value = 'RO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }

       <?php

       }
       function img_left_out_1JSClick($sender, $params)
       {
       ?>
       var type = document.getElementById('hfLO1').value;
       document.getElementById('hfTirePosMountSave').value='lo1_mount';
       document.getElementById('hfTirePosIdSave').value='lo1_tire_id';
       //document.getElementById("editMountVIN").value = document.getElementById('hiddenVin').value;

       if(type!=0)
       {
       document.getElementById("JTDivDismount").Show();
       document.getElementById("editDismountAxle").value = '1';
       document.getElementById("editDismountWheel").value = 'LO';

       var tire_id = document.getElementById('hfLO1').value;
       var vin = document.getElementById('hiddenVin').value;
       document.getElementById('hfTireIdEdit').value = tire_id;
       showTireDismount(tire_id, vin);
       //alert('dismount');
       }
       else
       {
       document.getElementById("JTDivAdd").Show();
       document.getElementById("editMountAxle").value = '1';
       document.getElementById("editMountWheel").value = 'LO';

       var axle = document.getElementById('editMountAxle').value;
       var wheel = document.getElementById('editMountWheel').value;
       var hiddenVin = document.getElementById('hiddenVin').value;
       var hfDescTireSn = document.getElementById('hfDescTireSn').value;
       document.getElementById('editMountDescription').value ='Mount Tire ID/SN:'+' '+hfDescTireSn;
       //alert('mount');
       }
       <?php
       }

       function generate_workorder()
       {
        $company_id = $_SESSION['company_id'];
        $result_wo = mysql_query("SELECT * FROM company_workorders_tbl WHERE company_id='".$company_id."'")
        or die("generate workorder ".mysql_error());
        $row_wo = mysql_fetch_array($result_wo);

        $auto_num = $row_wo['auto_numbering'];

        if($auto_num==1)
        {
        $this->editMountOrderNo->ReadOnly = true;
        $prefix = $row_wo['prefix'];
        $new_num = $row_wo['last_order_no'] + 1;
        $new_wo = $prefix.'-'.$new_num;
        }
        if($auto_num==0)
        {
        $this->editMountOrderNo->ReadOnly = false;
        $new_wo = $this->editMountOrderNo->Text;
        }
        return $new_wo;
       }

       function manage_tiresCreate($sender, $params)
       {
       $get_vin = $_GET['vin'];
       if(isset($get_vin))
       $this->hiddenVin->setValue($get_vin);

       //the following functions are arranged in proper sequence
       $this->vehicle_details();
       $this->checkAxleConfig();
       $this->updateHfFlags();
       $this->updateTireImages();
       $this->processComboAccount();
       $this->processOnShowComboWorkBy();
       $this->processFirstTire();
       $this->proccessDefaultValues();
       $this->generate_last_workorder();

       if($_SESSION['access_vehicle']==1)
       {
       $this->btnMountCancel->Visible=false;
       $this->btnAdd->Visible=false;
       $this->btnDismount->Visible=false;
       $this->btnDismountCancel->Visible=false;
       }

       if($_SESSION['access_vehicle']==2)
       {
       $this->btnMountCancel->Visible=true;
       $this->btnAdd->Visible=true;
       $this->btnDismount->Visible=true;
       $this->btnDismountCancel->Visible=true;
       }


       $result_vehicle = mysql_query("select * from vehicle_tbl where vehicle_id='".$this->hiddenVin->getValue()."'");
       $row_veh = mysql_fetch_array($result_vehicle);

       $track_by = $row_veh['track_by'];
       $stard_odometer = $row_veh['tracking_value'];
       $this->hfTrackBy->setValue($track_by);
       $this->hfStartOdometer->setValue($stard_odometer);
       if ($track_by=='distance')
        {
        $this->lblOdometer->Caption = 'Odometer';
        $this->lblOdometer2->Caption = 'Odometer';

        //$this->editDismountKm->Enabled = true;
        $this->lblKm->Visible = true;
        $this->lblkm2->Visible = true;
        $this->editMountKm->Visible = true;
        $this->editDismountKm->Visible = true;

        $this->editMountOdometer->Text=$row_veh['curr_tracking_value'];
        $this->editDismountOdometer->Text=$row_veh['curr_tracking_value'];
        }
       if ($track_by=='hours')
        {
        $this->lblOdometer->Caption = 'Hours';
        $this->lblOdometer2->Caption = 'Odometer';

        $this->lblKm->Visible = false;
        $this->lblkm2->Visible = false;
        $this->editMountKm->Visible = false;
        $this->editDismountKm->Visible = false;

        $this->editMountOdometer->Text=$row_veh['curr_hours'];
        $this->editDismountOdometer->Text=$row_veh['curr_hours'];
        }
       }
       function process_hints($tire_id)
       {
         $query_tire = "SELECT tire_SN, manufacturer FROM tire_inventory_tbl WHERE tire_id='".$tire_id."'";
         $result_tire = mysql_query($query_tire) or die("TIRE HINT ".mysql_error());
         $row_tire = mysql_fetch_array($result_tire);

         $sn = "";
         $manufacturer = "";

         $sn = $row_tire['tire_SN'];

         if(isset($row_tire['manufacturer']))
         $manufacturer = $row_tire['manufacturer']." - ";

         $hint = "Tire: ".$manufacturer.$sn;
         return $hint;
       }

       function vehicle_details()
       {
        $company_id = $_SESSION['company_id'];
        $result_vin = mysql_query("select VIN, year, manufacturer_name, model_name, veh_num from vehicle_tbl where company_id='".$company_id."' AND vehicle_id ='".$this->hiddenVin->getValue()."'") or die('SELECT VIN'.mysql_error());
        $row_vin = mysql_fetch_array($result_vin);
        $this->lblVeh->Caption=$row_vin['VIN'];
        $this->lblyear->Caption=$row_vin['year'];
        $this->lblmake->Caption=$row_vin['manufacturer_name'];
        $this->lblmodel->Caption=$row_vin['model_name'];
        $this->lblplate->Caption=$row_vin['veh_num'];

        $this->JTDivAdd->Left = 123;
        $this->JTDivAdd->Top = 137;

       $this->JTTireHistory->setUrl('frame_tire_history.php?veh='.$this->hiddenVin->getValue());
       $this->JTFrameTireList->setURL('frame_tire_list.php');
       $this->imgBack->setLink('vehicle_list.php?company_id='.$_SESSION['company_id']);
       }

       function generate_last_workorder()
       {
        $company_id = $_SESSION['company_id'];
        $result_wo = mysql_query("SELECT * FROM company_workorders_tbl WHERE company_id='".$company_id."'")
        or die("generate workorder ".mysql_error());
        $row_wo = mysql_fetch_array($result_wo);

        $auto_num = $row_wo['auto_numbering'];

        if($auto_num==1)
        {
        $this->editMountOrderNo->ReadOnly = true;
        $prefix = $row_wo['prefix'];
        $last_num = $row_wo['last_order_no']+1;
        $this->editMountOrderNo->Text = $prefix.'-'.$last_num;
        $this->editDismountOrderNo->Text = $prefix.'-'.$last_num;
        }
        if($auto_num==0)
        {
        $this->editMountOrderNo->ReadOnly = false;
        $this->editMountOrderNo->Text = '';
        }
       }

       function proccessDefaultValues()
       {
        $company_id = $_SESSION['company_id'];
        $vin = $this->hiddenVin->getValue();

        $query_tires = "select * from company_tires_tbl where company_id='".$company_id."'";
        $result_tires = mysql_query($query_tires) or die("COMPANY TIRES ".mysql_error());
        $row_tires = mysql_fetch_array($result_tires);

        $query_veh = "select * from vehicle_tbl where vehicle_id='".$vin."'";
        $result_veh = mysql_query($query_veh)or die("VEHICLE ".mysql_error());
        $row_veh = mysql_fetch_array($result_veh);
        //die($query_veh);

        $this->dpMountDate->setDate(date('Y-m-d'));
        $this->dpDismountDate->setDate(date('Y-m-d'));
        //$this->editMountTread->Text=$row_tires['tread'];
        //$this->editDismountTread->Text=$row_tires['tread'];
        //$this->editMountPressure->Text=$row_tires['pressure'];
        //$this->editDismountPressure->Text=$row_tires['pressure'];

        $this->editMountVIN->Text=$row_veh['VIN'];
        $this->editDismountVIN->Text=$row_veh['VIN'];
        $this->editMountOdometer->Text=$row_veh['curr_tracking_value'];
        $this->editDismountOdometer->Text=$row_veh['curr_tracking_value'];

        $this->chkMountRecord->Checked = 0;
        $this->chkDismountRecord->Checked = 0;
        $this->editMountCost->Text = '';
        $this->editDismountCostUnit->Text = '';
        $this->editMountLaborUnit->Text = '';
        $this->editDismountLaborUnit->Text = '';
        $this->memoMountComments->Lines = array();
        $this->memoDismountComments->Lines = array();
       }

       function processFirstTire()
       {
        $company_id = $_SESSION['company_id'];
        $query_tires = "SELECT tire_id, tire_SN, cost, curr_tread, curr_psi FROM tire_inventory_tbl WHERE status='0' AND company_id='".$company_id."' ORDER BY tire_id LIMIT 0,1";
        $result_tires = mysql_query($query_tires) or die("TIRES ".mysql_error());

        $row_tires = mysql_fetch_array($result_tires);
        $this->hfDescTireSn->setValue($row_tires['tire_SN']);
        $this->hiddenTireIdSave->setValue($row_tires['tire_id']);
        $this->editMountCost->setText($row_tires['cost']);

        $this->editMountTread->setText($row_tire['curr_tread']);
        $this->editMountPressure->setText($row_tire['curr_psi']);
       }
       function processOnShowComboWorkBy()
       {
        $company_id = $_SESSION['company_id'];
        $this->cmbMountWorkType->Clear();
        $this->cmbMountWorkType->AddItem('',null,'');
        $this->cmbDismountWorkby->Clear();
        $this->cmbDismountWorkby->AddItem('',null,'');

        $query_combo_work_by = "SELECT autoid, fname, lname FROM employee_tbl WHERE company_id='".$company_id."' AND
        (job_title='Driver' OR job_title='Fleet Technician')";
        $result_combo_work_by = mysql_query($query_combo_work_by) or die('COMBO WORK BY '.mysql_error());
        while($row_combo_work_by = mysql_fetch_array($result_combo_work_by))
         {
          $id = $row_combo_work_by['autoid'];
          $name = $row_combo_work_by['fname'].'&nbsp;'.$row_combo_work_by['lname'];
          $this->cmbMountWorkType->AddItem($name,null,$id);
          $this->cmbDismountWorkby->AddItem($name,null,$id);
         }
       }

       function processComboAccount()
       {
        $company_id = $_SESSION['company_id'];
        $this->cmbMountAccount->Clear();
        $this->cmbMountAccount->AddItem('',null,'');
        $this->cmbDismountAccount->Clear();
        $this->cmbDismountAccount->AddItem('',null,'');
        $query_accounts = "SELECT id,value FROM lookup_expense_tbl WHERE category='accounts' AND company_id='".$company_id."'";
        $result_accounts = mysql_query($query_accounts) or die("ACCOUNTS ".mysql_error());
        while($row_accounts = mysql_fetch_array($result_accounts))
        {
         $id = $row_accounts['id'];
         $value = $row_accounts['value'];
         $this->cmbMountAccount->AddItem($value,null,$id);
         $this->cmbDismountAccount->AddItem($value,null,$id);
        }
       }

       function updateHfFlags()
       {
       $vin = $this->hiddenVin->getValue();
       $query_chassis_tire = "SELECT * FROM veh_chassis_tire_tbl WHERE vehicle_id='".$vin."'";
       $result_chassis_tire = mysql_query($query_chassis_tire) or die("CHASSIS TIRE ".mysql_error());
       $row_chassis_tire = mysql_fetch_array($result_chassis_tire);

       $this->hfSpareTire->setValue($row_chassis_tire['spare_mount']);

       $this->hfLeftOut1->setValue($row_chassis_tire['lo1_mount']);
       $this->hfLeftIn1->setValue($row_chassis_tire['li1_mount']);
       $this->hfLeftOut2->setValue($row_chassis_tire['lo2_mount']);
       $this->hfLeftIn2->setValue($row_chassis_tire['li2_mount']);
       $this->hfLeftOut3->setValue($row_chassis_tire['lo3_mount']);
       $this->hfLeftIn3->setValue($row_chassis_tire['li3_mount']);
       $this->hfLeftOut4->setValue($row_chassis_tire['lo4_mount']);
       $this->hfLeftIn4->setValue($row_chassis_tire['li4_mount']);
       $this->hfLeftOut5->setValue($row_chassis_tire['lo5_mount']);
       $this->hfLeftIn5->setValue($row_chassis_tire['li5_mount']);
       $this->hfLeftOut6->setValue($row_chassis_tire['lo6_mount']);
       $this->hfLeftIn6->setValue($row_chassis_tire['li6_mount']);

       $this->hfRightOut1->setValue($row_chassis_tire['ro1_mount']);
       $this->hfRightIn1->setValue($row_chassis_tire['ri1_mount']);
       $this->hfRightOut1->setValue($row_chassis_tire['ro2_mount']);
       $this->hfRightIn1->setValue($row_chassis_tire['ri2_mount']);
       $this->hfRightOut1->setValue($row_chassis_tire['ro3_mount']);
       $this->hfRightIn1->setValue($row_chassis_tire['ri3_mount']);
       $this->hfRightOut1->setValue($row_chassis_tire['ro4_mount']);
       $this->hfRightIn1->setValue($row_chassis_tire['ri4_mount']);
       $this->hfRightOut1->setValue($row_chassis_tire['ro5_mount']);
       $this->hfRightIn1->setValue($row_chassis_tire['ri5_mount']);
       $this->hfRightOut1->setValue($row_chassis_tire['ro6_mount']);
       $this->hfRightIn1->setValue($row_chassis_tire['ri6_mount']);


       $this->hfSpare->setValue($row_chassis_tire['spare_tire_id']);

       $this->hfLO1->setValue($row_chassis_tire['lo1_tire_id']);
       $this->hfLI1->setValue($row_chassis_tire['li1_tire_id']);
       $this->hfLO2->setValue($row_chassis_tire['lo2_tire_id']);
       $this->hfLI2->setValue($row_chassis_tire['li2_tire_id']);
       $this->hfLO3->setValue($row_chassis_tire['lo3_tire_id']);
       $this->hfLI3->setValue($row_chassis_tire['li3_tire_id']);
       $this->hfLO4->setValue($row_chassis_tire['lo4_tire_id']);
       $this->hfLI4->setValue($row_chassis_tire['li4_tire_id']);
       $this->hfLO5->setValue($row_chassis_tire['lo5_tire_id']);
       $this->hfLI5->setValue($row_chassis_tire['li5_tire_id']);
       $this->hfLO6->setValue($row_chassis_tire['lo6_tire_id']);
       $this->hfLI6->setValue($row_chassis_tire['li6_tire_id']);

       $this->hfRO1->setValue($row_chassis_tire['ro1_tire_id']);
       $this->hfRI1->setValue($row_chassis_tire['ri1_tire_id']);
       $this->hfRO2->setValue($row_chassis_tire['ro2_tire_id']);
       $this->hfRI2->setValue($row_chassis_tire['ri2_tire_id']);
       $this->hfRO3->setValue($row_chassis_tire['ro3_tire_id']);
       $this->hfRI3->setValue($row_chassis_tire['ri3_tire_id']);
       $this->hfRO4->setValue($row_chassis_tire['ro4_tire_id']);
       $this->hfRI4->setValue($row_chassis_tire['ri4_tire_id']);
       $this->hfRO5->setValue($row_chassis_tire['ro5_tire_id']);
       $this->hfRI5->setValue($row_chassis_tire['ri5_tire_id']);
       $this->hfRO6->setValue($row_chassis_tire['ro6_tire_id']);
       $this->hfRI6->setValue($row_chassis_tire['ri6_tire_id']);
       }
       function updateTireImages()
       {
       //THIS FUNCTION INCLUDES HINTS
       $vin = $this->hiddenVin->getValue();
       $query_chassis_tire = "SELECT * FROM veh_chassis_tire_tbl WHERE vehicle_id='".$vin."'";
       $result_chassis_tire = mysql_query($query_chassis_tire) or die("CHASSIS TIRE ".mysql_error());
       $row_chassis_tire = mysql_fetch_array($result_chassis_tire);

       $this->img_spare->setImageSource('image/front_tire.png');

       $this->img_left_out_1->setImageSource('image/new_tire.png');
       $this->img_left_in_1->setImageSource('image/new_tire.png');
       $this->img_right_in_1->setImageSource('image/new_tire.png');
       $this->img_right_out_1->setImageSource('image/new_tire.png');

       $this->img_left_out_2->setImageSource('image/new_tire.png');
       $this->img_left_in_2->setImageSource('image/new_tire.png');
       $this->img_right_in_2->setImageSource('image/new_tire.png');
       $this->img_right_out_2->setImageSource('image/new_tire.png');

       $this->img_left_out_3->setImageSource('image/new_tire.png');
       $this->img_left_in_3->setImageSource('image/new_tire.png');
       $this->img_right_in_3->setImageSource('image/new_tire.png');
       $this->img_right_out_3->setImageSource('image/new_tire.png');

       $this->img_left_out_4->setImageSource('image/new_tire.png');
       $this->img_left_in_4->setImageSource('image/new_tire.png');
       $this->img_right_in_4->setImageSource('image/new_tire.png');
       $this->img_right_out_4->setImageSource('image/new_tire.png');

       $this->img_left_out_5->setImageSource('image/new_tire.png');
       $this->img_left_in_5->setImageSource('image/new_tire.png');
       $this->img_right_in_5->setImageSource('image/new_tire.png');
       $this->img_right_out_5->setImageSource('image/new_tire.png');

       $this->img_left_out_6->setImageSource('image/new_tire.png');
       $this->img_left_in_6->setImageSource('image/new_tire.png');
       $this->img_right_in_6->setImageSource('image/new_tire.png');
       $this->img_right_out_6->setImageSource('image/new_tire.png');

       $spare_id = $row_chassis_tire['spare_tire_id'];

       $lo_id1 = $row_chassis_tire['lo1_tire_id'];
       $li_id1 = $row_chassis_tire['li1_tire_id'];
       $ri_id1 = $row_chassis_tire['ri1_tire_id'];
       $ro_id1 = $row_chassis_tire['ro1_tire_id'];

       $lo_id2 = $row_chassis_tire['lo2_tire_id'];
       $li_id2 = $row_chassis_tire['li2_tire_id'];
       $ri_id2 = $row_chassis_tire['ri2_tire_id'];
       $ro_id2 = $row_chassis_tire['ro2_tire_id'];

       $lo_id3 = $row_chassis_tire['lo3_tire_id'];
       $li_id3 = $row_chassis_tire['li3_tire_id'];
       $ri_id3 = $row_chassis_tire['ri3_tire_id'];
       $ro_id3 = $row_chassis_tire['ro3_tire_id'];

       $lo_id4 = $row_chassis_tire['lo4_tire_id'];
       $li_id4 = $row_chassis_tire['li4_tire_id'];
       $ri_id4 = $row_chassis_tire['ri4_tire_id'];
       $ro_id4 = $row_chassis_tire['ro4_tire_id'];

       $lo_id5 = $row_chassis_tire['lo5_tire_id'];
       $li_id5 = $row_chassis_tire['li5_tire_id'];
       $ri_id5 = $row_chassis_tire['ri5_tire_id'];
       $ro_id5 = $row_chassis_tire['ro5_tire_id'];

       $lo_id6 = $row_chassis_tire['lo6_tire_id'];
       $li_id6 = $row_chassis_tire['li6_tire_id'];
       $ri_id6 = $row_chassis_tire['ri6_tire_id'];
       $ro_id6 = $row_chassis_tire['ro6_tire_id'];


       $spare = $row_chassis_tire['spare_mount'];

       $lo1 = $row_chassis_tire['lo1_mount'];
       $li1 = $row_chassis_tire['li1_mount'];
       $ri1 = $row_chassis_tire['ri1_mount'];
       $ro1 = $row_chassis_tire['ro1_mount'];

       $lo2 = $row_chassis_tire['lo2_mount'];
       $li2 = $row_chassis_tire['li2_mount'];
       $ri2 = $row_chassis_tire['ri2_mount'];
       $ro2 = $row_chassis_tire['ro2_mount'];

       $lo3 = $row_chassis_tire['lo3_mount'];
       $li3 = $row_chassis_tire['li3_mount'];
       $ri3 = $row_chassis_tire['ri3_mount'];
       $ro3 = $row_chassis_tire['ro3_mount'];

       $lo4 = $row_chassis_tire['lo4_mount'];
       $li4 = $row_chassis_tire['li4_mount'];
       $ri4 = $row_chassis_tire['ri4_mount'];
       $ro4 = $row_chassis_tire['ro4_mount'];

       $lo5 = $row_chassis_tire['lo5_mount'];
       $li5 = $row_chassis_tire['li5_mount'];
       $ri5 = $row_chassis_tire['ri5_mount'];
       $ro5 = $row_chassis_tire['ro5_mount'];

       $lo6 = $row_chassis_tire['lo6_mount'];
       $li6 = $row_chassis_tire['li6_mount'];
       $ri6 = $row_chassis_tire['ri6_mount'];
       $ro6 = $row_chassis_tire['ro6_mount'];


       if($spare==0)
       $this->img_spare->setImageSource('image/front_tire2.png');

       if($lo1==0)
       $this->img_left_out_1->setImageSource('image/old_tire.png');
       if($li1==0)
       $this->img_left_in_1->setImageSource('image/old_tire.png');
       if($ri1==0)
       $this->img_right_in_1->setImageSource('image/old_tire.png');
       if($ro1==0)
       $this->img_right_out_1->setImageSource('image/old_tire.png');


       if($lo2==0)
       $this->img_left_out_2->setImageSource('image/old_tire.png');
       if($li2==0)
       $this->img_left_in_2->setImageSource('image/old_tire.png');
       if($ri2==0)
       $this->img_right_in_2->setImageSource('image/old_tire.png');
       if($ro2==0)
       $this->img_right_out_2->setImageSource('image/old_tire.png');


       if($lo3==0)
       $this->img_left_out_3->setImageSource('image/old_tire.png');
       if($li3==0)
       $this->img_left_in_3->setImageSource('image/old_tire.png');
       if($ri3==0)
       $this->img_right_in_3->setImageSource('image/old_tire.png');
       if($ro3==0)
       $this->img_right_out_3->setImageSource('image/old_tire.png');


       if($lo4==0)
       $this->img_left_out_4->setImageSource('image/old_tire.png');
       if($li4==0)
       $this->img_left_in_4->setImageSource('image/old_tire.png');
       if($ri4==0)
       $this->img_right_in_4->setImageSource('image/old_tire.png');
       if($ro4==0)
       $this->img_right_out_4->setImageSource('image/old_tire.png');


       if($lo5==0)
       $this->img_left_out_5->setImageSource('image/old_tire.png');
       if($li5==0)
       $this->img_left_in_5->setImageSource('image/old_tire.png');
       if($ri5==0)
       $this->img_right_in_5->setImageSource('image/old_tire.png');
       if($ro5==0)
       $this->img_right_out_5->setImageSource('image/old_tire.png');

       if($lo6==0)
       $this->img_left_out_6->setImageSource('image/old_tire.png');
       if($li6==0)
       $this->img_left_in_6->setImageSource('image/old_tire.png');
       if($ri6==0)
       $this->img_right_in_6->setImageSource('image/old_tire.png');
       if($ro6==0)
       $this->img_right_out_6->setImageSource('image/old_tire.png');


       if($spare!=0 && $spare_id==0)
       $this->img_spare->setImageSource('image/front_tire3.png');

       if($lo1!=0 && $lo_id1==0)
       $this->img_left_out_1->setImageSource('image/dismount_tire.png');
       if($li1!=0 && $li_id1==0)
       $this->img_left_in_1->setImageSource('image/dismount_tire.png');
       if($ri1!=0 && $ri_id1==0)
       $this->img_right_in_1->setImageSource('image/dismount_tire.png');
       if($ro1!=0 && $ro_id1==0)
       $this->img_right_out_1->setImageSource('image/dismount_tire.png');


       if($lo2!=0 && $lo_id2==0)
       $this->img_left_out_2->setImageSource('image/dismount_tire.png');
       if($li2!=0 && $li_id2==0)
       $this->img_left_in_2->setImageSource('image/dismount_tire.png');
       if($ri2!=0 && $ri_id2==0)
       $this->img_right_in_2->setImageSource('image/dismount_tire.png');
       if($ro2!=0 && $ro_id2==0)
       $this->img_right_out_2->setImageSource('image/dismount_tire.png');


       if($lo3!=0 && $lo_id3==0)
       $this->img_left_out_3->setImageSource('image/dismount_tire.png');
       if($li3!=0 && $li_id3==0)
       $this->img_left_in_3->setImageSource('image/dismount_tire.png');
       if($ri3!=0 && $ri_id3==0)
       $this->img_right_in_3->setImageSource('image/dismount_tire.png');
       if($ro3!=0 && $ro_id3==0)
       $this->img_right_out_3->setImageSource('image/dismount_tire.png');


       if($lo4!=0 && $lo_id4==0)
       $this->img_left_out_4->setImageSource('image/dismount_tire.png');
       if($li4!=0 && $li_id4==0)
       $this->img_left_in_4->setImageSource('image/dismount_tire.png');
       if($ri4!=0 && $ri_id4==0)
       $this->img_right_in_4->setImageSource('image/dismount_tire.png');
       if($ro4!=0 && $ro_id4==0)
       $this->img_right_out_4->setImageSource('image/dismount_tire.png');


       if($lo5!=0 && $lo_id5==0)
       $this->img_left_out_5->setImageSource('image/dismount_tire.png');
       if($li5!=0 && $li_id5==0)
       $this->img_left_in_5->setImageSource('image/dismount_tire.png');
       if($ri5!=0 && $ri_id5==0)
       $this->img_right_in_5->setImageSource('image/dismount_tire.png');
       if($ro5!=0 && $ro_id5==0)
       $this->img_right_out_5->setImageSource('image/dismount_tire.png');

       if($lo6!=0 && $lo_id6==0)
       $this->img_left_out_6->setImageSource('image/dismount_tire.png');
       if($li6!=0 && $li_id6==0)
       $this->img_left_in_6->setImageSource('image/dismount_tire.png');
       if($ri6!=0 && $ri_id6==0)
       $this->img_right_in_6->setImageSource('image/dismount_tire.png');
       if($ro6!=0 && $ro_id6==0)
       $this->img_right_out_6->setImageSource('image/dismount_tire.png');


       $this->img_spare->setHint('no tire details');

       $this->img_left_out_1->setHint('no tire details');
       $this->img_left_in_1->setHint('no tire details');
       $this->img_right_in_1->setHint('no tire details');
       $this->img_right_out_1->setHint('no tire details');

       $this->img_left_out_2->setHint('no tire details');
       $this->img_left_in_2->setHint('no tire details');
       $this->img_right_in_2->setHint('no tire details');
       $this->img_right_out_2->setHint('no tire details');

       $this->img_left_out_3->setHint('no tire details');
       $this->img_left_in_3->setHint('no tire details');
       $this->img_right_in_3->setHint('no tire details');
       $this->img_right_out_3->setHint('no tire details');

       $this->img_left_out_4->setHint('no tire details');
       $this->img_left_in_4->setHint('no tire details');
       $this->img_right_in_4->setHint('no tire details');
       $this->img_right_out_4->setHint('no tire details');

       $this->img_left_out_5->setHint('no tire details');
       $this->img_left_in_5->setHint('no tire details');
       $this->img_right_in_5->setHint('no tire details');
       $this->img_right_out_5->setHint('no tire details');

       $this->img_left_out_6->setHint('no tire details');
       $this->img_left_in_6->setHint('no tire details');
       $this->img_right_in_6->setHint('no tire details');
       $this->img_right_out_6->setHint('no tire details');

       if($this->hfSpare->getValue()!=0)
       $this->img_spare->setHint($this->process_hints($this->hfSpare->getValue()));

       if($this->hfLO1->getValue()!=0)
       $this->img_left_out_1->setHint($this->process_hints($this->hfLO1->getValue()));
       if($this->hfLI1->getValue()!=0)
       $this->img_left_in_1->setHint($this->process_hints($this->hfLI1->getValue()));
       if($this->hfRI1->getValue()!=0)
       $this->img_right_in_1->setHint($this->process_hints($this->hfRI1->getValue()));
       if($this->hfRO1->getValue()!=0)
       $this->img_right_out_1->setHint($this->process_hints($this->hfRO1->getValue()));

       if($this->hfLO2->getValue()!=0)
       $this->img_left_out_2->setHint($this->process_hints($this->hfLO2->getValue()));
       if($this->hfLO2->getValue()!=0)
       $this->img_left_in_2->setHint($this->process_hints($this->hfLO2->getValue()));
       if($this->hfLO2->getValue()!=0)
       $this->img_right_in_2->setHint($this->process_hints($this->hfLO2->getValue()));
       if($this->hfLO2->getValue()!=0)
       $this->img_right_out_2->setHint($this->process_hints($this->hfLO2->getValue()));

       if($this->hfLO3->getValue()!=0)
       $this->img_left_out_3->setHint($this->process_hints($this->hfLO3->getValue()));
       if($this->hfLO3->getValue()!=0)
       $this->img_left_in_3->setHint($this->process_hints($this->hfLO3->getValue()));
       if($this->hfLO3->getValue()!=0)
       $this->img_right_in_3->setHint($this->process_hints($this->hfLO3->getValue()));
       if($this->hfLO3->getValue()!=0)
       $this->img_right_out_3->setHint($this->process_hints($this->hfLO3->getValue()));

       if($this->hfLO4->getValue()!=0)
       $this->img_left_out_4->setHint($this->process_hints($this->hfLO4->getValue()));
       if($this->hfLO4->getValue()!=0)
       $this->img_left_in_4->setHint($this->process_hints($this->hfLO4->getValue()));
       if($this->hfLO4->getValue()!=0)
       $this->img_right_in_4->setHint($this->process_hints($this->hfLO4->getValue()));
       if($this->hfLO4->getValue()!=0)
       $this->img_right_out_4->setHint($this->process_hints($this->hfLO4->getValue()));

       if($this->hfLO5->getValue()!=0)
       $this->img_left_out_5->setHint($this->process_hints($this->hfLO5->getValue()));
       if($this->hfLO5->getValue()!=0)
       $this->img_left_in_5->setHint($this->process_hints($this->hfLO5->getValue()));
       if($this->hfLO5->getValue()!=0)
       $this->img_right_in_5->setHint($this->process_hints($this->hfLO5->getValue()));
       if($this->hfLO5->getValue()!=0)
       $this->img_right_out_5->setHint($this->process_hints($this->hfLO5->getValue()));

       if($this->hfLO6->getValue()!=0)
       $this->img_left_out_6->setHint($this->process_hints($this->hfLO6->getValue()));
       if($this->hfLO6->getValue()!=0)
       $this->img_left_in_6->setHint($this->process_hints($this->hfLO6->getValue()));
       if($this->hfLO6->getValue()!=0)
       $this->img_right_in_6->setHint($this->process_hints($this->hfLO6->getValue()));
       if($this->hfLO6->getValue()!=0)
       $this->img_right_out_6->setHint($this->process_hints($this->hfLO6->getValue()));
       }
       function checkTireTblExist()
       {
       $vin = $this->hiddenVin->getValue();
       $new = 0;

       $query_check = "SELECT * FROM veh_chassis_tire_tbl WHERE vehicle_id='".$vin."'";
       $result_check = mysql_query($query_check) or die("CHECK ".mysql_error());
       $count_check = mysql_num_rows($result_check);

       if($count_check==0)
       {
       mysql_query("INSERT INTO veh_chassis_tire_tbl (vehicle_id) VALUES ('".$vin."')");
       $new = 1;
       }
       return $new;
       }

       function checkAxleConfig()
       {
       //this includes the update on the db flags
       //and processing of labels
       $vin = $this->hiddenVin->getValue();
       $new = $this->checkTireTblExist();

       $query_chassis = "SELECT * FROM veh_chassis_tbl WHERE vehicle_id='".$vin."'";
       $result_chassis = mysql_query($query_chassis) or die("SELECT CHASSIS ".mysql_error());
       $row_chassis = mysql_fetch_array($result_chassis);

       $single_1 = $row_chassis['single_axle1'];
       $single_2 = $row_chassis['single_axle2'];
       $single_3 = $row_chassis['single_axle3'];
       $single_4 = $row_chassis['single_axle4'];
       $single_5 = $row_chassis['single_axle5'];
       $single_6 = $row_chassis['single_axle6'];

       $dual_1 = $row_chassis['dual_axle1'];
       $dual_2 = $row_chassis['dual_axle2'];
       $dual_3 = $row_chassis['dual_axle3'];
       $dual_4 = $row_chassis['dual_axle4'];
       $dual_5 = $row_chassis['dual_axle5'];
       $dual_6 = $row_chassis['dual_axle6'];

       $dual_check = $dual_1 + $dual_2 + $dual_3 + $dual_4 + $dual_5 + $dual_6;
       $axle1_check = $single_1 + $dual_1;
       $axle2_check = $single_2 + $dual_2;
       $axle3_check = $single_3 + $dual_3;
       $axle4_check = $single_4 + $dual_4;
       $axle5_check = $single_5 + $dual_5;
       $axle6_check = $single_6 + $dual_6;


       //PROCESS LABELS
       $this->lbl1->setVisible(true);
       $this->lbl2->setVisible(true);
       $this->lbl3->setVisible(true);
       $this->lbl4->setVisible(true);
       $this->lbl5->setVisible(true);
       $this->lbl6->setVisible(true);

       $this->lblLO->setVisible(true);
       $this->lblLI->setVisible(true);
       $this->lblRI->setVisible(true);
       $this->lblRO->setVisible(true);
       if($dual_check==0)
       {
        $this->lblRI->setVisible(false);
        $this->lblLI->setVisible(false);
       }

       if($axle1_check==0)
        $this->lbl1->setVisible(false);
       if($axle2_check==0)
        $this->lbl2->setVisible(false);
       if($axle3_check==0)
        $this->lbl3->setVisible(false);
       if($axle4_check==0)
        $this->lbl4->setVisible(false);
       if($axle5_check==0)
        $this->lbl5->setVisible(false);
       if($axle6_check==0)
        $this->lbl6->setVisible(false);
       //END LABELS


       $this->img_left_in_1->setVisible(true);
       $this->img_right_in_1->setVisible(true);
       $this->img_left_in_2->setVisible(true);
       $this->img_right_in_2->setVisible(true);
       $this->img_left_in_3->setVisible(true);
       $this->img_right_in_3->setVisible(true);
       $this->img_left_in_4->setVisible(true);
       $this->img_right_in_4->setVisible(true);
       $this->img_left_in_5->setVisible(true);
       $this->img_right_in_5->setVisible(true);
       $this->img_left_in_6->setVisible(true);
       $this->img_right_in_6->setVisible(true);

       $this->img_left_out_1->setVisible(true);
       $this->img_right_out_1->setVisible(true);
       $this->img_bar_1->setVisible(true);
       $this->img_left_out_2->setVisible(true);
       $this->img_right_out_2->setVisible(true);
       $this->img_bar_2->setVisible(true);
       $this->img_left_out_3->setVisible(true);
       $this->img_right_out_3->setVisible(true);
       $this->img_bar_3->setVisible(true);
       $this->img_left_out_4->setVisible(true);
       $this->img_right_out_4->setVisible(true);
       $this->img_bar_4->setVisible(true);
       $this->img_left_out_5->setVisible(true);
       $this->img_right_out_5->setVisible(true);
       $this->img_bar_5->setVisible(true);
       $this->img_left_out_6->setVisible(true);
       $this->img_right_out_6->setVisible(true);
       $this->img_bar_6->setVisible(true);

       if($new==1)
       {
       $left_out_save_1 = 1;
       $left_in_save_1 = 1;
       $left_out_save_2 = 1;
       $left_in_save_2 = 1;
       $left_out_save_3 = 1;
       $left_in_save_3 = 1;
       $left_out_save_4 = 1;
       $left_in_save_4 = 1;
       $left_out_save_5 = 1;
       $left_in_save_5 = 1;
       $left_out_save_6 = 1;
       $left_in_save_6 = 1;

       $right_out_save_1 = 1;
       $right_in_save_1 = 1;
       $right_out_save_2 = 1;
       $right_in_save_2 = 1;
       $right_out_save_3 = 1;
       $right_in_save_3 = 1;
       $right_out_save_4 = 1;
       $right_in_save_4 = 1;
       $right_out_save_5 = 1;
       $right_in_save_5 = 1;
       $right_out_save_6 = 1;
       $right_in_save_6 = 1;
       }

       //SINGLE 1 DUAL 0
       if($dual_1==0)
       {
       $this->img_left_in_1->setVisible(false);
       $this->img_right_in_1->setVisible(false);

       $left_in_save_1 = 0;
       $right_in_save_1 = 0;
       }

       if($dual_2==0)
       {
       $this->img_left_in_2->setVisible(false);
       $this->img_right_in_2->setVisible(false);

       $left_in_save_2 = 0;
       $right_in_save_2 = 0;
       }

       if($dual_3==0)
       {
       $this->img_left_in_3->setVisible(false);
       $this->img_right_in_3->setVisible(false);

       $left_in_save_3 = 0;
       $right_in_save_3 = 0;
       }

       if($dual_4==0)
       {
       $this->img_left_in_4->setVisible(false);
       $this->img_right_in_4->setVisible(false);

       $left_in_save_4 = 0;
       $right_in_save_4 = 0;
       }

       if($dual_5==0)
       {
       $this->img_left_in_5->setVisible(false);
       $this->img_right_in_5->setVisible(false);

       $left_in_save_5 = 0;
       $right_in_save_5 = 0;
       }

       if($dual_6==0)
       {
       $this->img_left_in_6->setVisible(false);
       $this->img_right_in_6->setVisible(false);

       $left_in_save_6 = 0;
       $right_in_save_6 = 0;
       }


       //SINGLE AND DUAL 0
       if($single_1==0 && $dual_1==0)
       {
       $this->img_left_out_1->setVisible(false);
       $this->img_right_out_1->setVisible(false);
       $this->img_bar_1->setVisible(false);

       $left_out_save_1 = 0;
       $right_out_save_1 = 0;
       }

       if($single_2==0 && $dual_2==0)
       {
       $this->img_left_out_2->setVisible(false);
       $this->img_right_out_2->setVisible(false);
       $this->img_bar_2->setVisible(false);

       $left_out_save_2 = 0;
       $right_out_save_2 = 0;
       }

       if($single_3==0 && $dual_3==0)
       {
       $this->img_left_out_3->setVisible(false);
       $this->img_right_out_3->setVisible(false);
       $this->img_bar_3->setVisible(false);

       $left_out_save_3 = 0;
       $right_out_save_3 = 0;
       }

       if($single_4==0 && $dual_4==0)
       {
       $this->img_left_out_4->setVisible(false);
       $this->img_right_out_4->setVisible(false);
       $this->img_bar_4->setVisible(false);

       $left_out_save_4 = 0;
       $right_out_save_4 = 0;
       }

       if($single_5==0 && $dual_5==0)
       {
       $this->img_left_out_5->setVisible(false);
       $this->img_right_out_5->setVisible(false);
       $this->img_bar_5->setVisible(false);

       $left_out_save_5 = 0;
       $right_out_save_5 = 0;
       }

       if($single_6==0 && $dual_6==0)
       {
       $this->img_left_out_6->setVisible(false);
       $this->img_right_out_6->setVisible(false);
       $this->img_bar_6->setVisible(false);

       $left_out_save_6 = 0;
       $right_out_save_6 = 0;
       }

       if($new==1)
       {
       $query_update_flags = "UPDATE veh_chassis_tire_tbl SET
       lo1_mount='$left_out_save_1',
       li1_mount='$left_in_save_1',
       lo2_mount='$left_out_save_2',
       li2_mount='$left_in_save_2',
       lo3_mount='$left_out_save_3',
       li3_mount='$left_in_save_3',
       lo4_mount='$left_out_save_4',
       li4_mount='$left_in_save_4',
       lo5_mount='$left_out_save_5',
       li5_mount='$left_in_save_5',
       lo6_mount='$left_out_save_6',
       li6_mount='$left_in_save_6',
       ro1_mount='$right_out_save_1',
       ri1_mount='$right_in_save_1',
       ro2_mount='$right_out_save_2',
       ri2_mount='$right_in_save_2',
       ro3_mount='$right_out_save_3',
       ri3_mount='$right_in_save_3',
       ro4_mount='$right_out_save_4',
       ri4_mount='$right_in_save_4',
       ro5_mount='$right_out_save_5',
       ri5_mount='$right_in_save_5',
       ro6_mount='$right_out_save_6',
       ri6_mount='$right_in_save_6'
       WHERE vehicle_id='$vin'
       ";
       mysql_query($query_update_flags) or die("UPDATE DB FLAGS ".mysql_error());
       }
       }

}

global $application;

global $manage_tires;

//Creates the form
$manage_tires=new manage_tires($application);

//Read from resource file
$manage_tires->loadResource(__FILE__);

//Shows the form
$manage_tires->show();

?>